package com.kaifamiao.thread.d0928.pm;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class UDPServer {

    public static void main(String[] args) throws Exception {
        DatagramSocket socket = new DatagramSocket(8888);

        byte[] bytes = new byte[1024];
        DatagramPacket packet = new DatagramPacket(bytes, bytes.length);

        while (true){
            socket.receive(packet); // 接收信息

            int length = packet.getLength();

//        System.out.println(new String(packet.getData(), 0, length));

            System.out.println(new String(bytes, 0, length));
        }

    }
}
